#!/usr/bin/perl

$file = $0;
$file =~ s#/MacOS/foxbox##;
$path = "/Applications/InterWebPPC.app"; # fallback
chomp($machine = `/usr/bin/machine`);
$path = "/Applications/InterWebPPC-G3.app";
$path = "/Applications/InterWebPPC-G4.app" if ($machine eq 'ppc7450');
$path = "/Applications/InterWebPPC-G5.app" if ($machine eq 'ppc970');
$path = "/Applications/TenFourFoxBoxRunner.app" if (-x
	"/Applications/TenFourFoxBoxRunner.app/Contents/MacOS/firefox");

	if (! -d $path || ! -x "$path/Contents/MacOS/interwebppc") {
		if (-x "/Applications/InterWebPPC.app/Contents/MacOS/interwebppc") {
			$path = "/Applications/InterWebPPC.app";
		} else {
			&dialogue("Couldn't find $path!");
		}
	}

exec("\"$path/Contents/MacOS/interwebppc\" -app \"$file/Resources/foxbox/application.ini\"");
&dialogue("Failed to execute: $!\n");
sub dialogue {
	open(O, "|/usr/bin/osascript") || (print "Can't open osascript; $!\n", exit);
	print O <<"EOG";
tell application "Dock"
	activate
	display dialog "@_" buttons ("OK") default button "OK"
	set answername to button returned of the result
end tell
EOG
	close(O);
	exit;
}

